#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>

#define FILE_NAME "log.txt"

int main()
{
  //int fd = open(FILE_NAME,O_WRONLY | O_CREAT | O_APPEND ,0666);
  int fd = open(FILE_NAME, O_RDONLY);
  if(fd<0)
  {
    perror("open");
    return 1;
  }

  char buffer[1024];
  ssize_t num = read(fd,buffer,sizeof(buffer)-1);
  if(num > 0)
  {
    buffer[num] = 0;
  }

  printf("%s",buffer);


//  int cnt = 5;
//  char outBuffer[64];
//  while(cnt)
//  {
//    sprintf(outBuffer,"%s:%d\n","aaaa",cnt--);
//    write(fd,outBuffer,strlen(outBuffer));
//  }
  
  close(fd);
  return 0;
}




